/* 聊天容器 */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* 聊天头部 */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
}

.back-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.back-icon {
  font-size: 20px;
  font-weight: bold;
  color: #333;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #667eea;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.status {
  font-size: 12px;
  color: #4CAF50;
  font-weight: 500;
}

.doctor-title {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
  display: block;
}

.chat-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.icon {
  font-size: 18px;
}

/* 消息容器 */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
}

/* 消息样式 */
.message {
  display: flex;
  margin-bottom: 8px;
}

.message-user {
  justify-content: flex-end;
}

.message-other {
  justify-content: flex-start;
}

.message-content {
  max-width: 70%;
  display: flex;
  flex-direction: column;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
}

.message-user .message-bubble {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-other .message-bubble {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-time {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 4px;
  text-align: right;
}

.message-other .message-time {
  color: rgba(0, 0, 0, 0.5);
  text-align: left;
}

/* 输入区域 */
.input-container {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  padding: 16px 20px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.message-input {
  flex: 1;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  background: white;
  min-height: 20px;
  max-height: 120px;
}

.message-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.message-input::placeholder {
  color: #999;
}

.send-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-icon {
  font-size: 16px;
  color: white;
}

.input-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.input-actions .action-btn {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  width: 36px;
  height: 36px;
}

.input-actions .action-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.input-actions .icon {
  font-size: 16px;
}

/* 滚动条样式 */
.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .chat-header {
    padding: 12px 16px;
  }
  
  .chat-header-left {
    gap: 8px;
  }
  
  .back-btn {
    padding: 6px;
    margin-right: 6px;
  }
  
  .back-icon {
    font-size: 18px;
  }
  
  .messages-container {
    padding: 16px;
  }
  
  .input-container {
    padding: 12px 16px;
  }
  
  .message-content {
    max-width: 85%;
  }
  
  .chat-actions {
    gap: 4px;
  }
  
  .action-btn {
    padding: 6px;
  }
}

/* 动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message {
  animation: fadeIn 0.3s ease-out;
}

/* 加载状态 */
.message-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

/* 错误状态 */
.message-input.error {
  border-color: #ff4757;
  box-shadow: 0 0 0 3px rgba(255, 71, 87, 0.1);
}

/* 正在输入状态 */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  font-size: 12px;
  color: #666;
}

.typing-dots {
  display: flex;
  gap: 2px;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 连接状态样式 */
.status.online {
  color: #4CAF50;
}

.status.offline {
  color: #f44336;
}

/* AI徽章样式 */
.ai-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.message-user .ai-badge {
  display: none;
}

/* 输入状态指示器 */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  font-size: 12px;
  color: #666;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 连接状态指示器 */
.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.connection-status.connecting {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
}

.connection-status.connected {
  background: rgba(76, 175, 80, 0.2);
  color: #4caf50;
}

.connection-status.disconnected {
  background: rgba(244, 67, 54, 0.2);
  color: #f44336;
}

/* 重新连接按钮样式 */
.action-btn.reconnect {
  background: rgba(255, 193, 7, 0.1);
  color: #ffc107;
}

.action-btn.reconnect:hover {
  background: rgba(255, 193, 7, 0.2);
}

/* 消息输入框禁用状态 */
.message-input:disabled {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

/* 发送按钮禁用状态 */
.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.send-button:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* 输入操作按钮禁用状态 */
.input-actions .action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-actions .action-btn:disabled:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* 消息动画增强 */
.message {
  animation: fadeIn 0.3s ease-out;
  transition: all 0.2s ease;
}

.message:hover {
  transform: translateY(-1px);
}

/* 连接状态文本样式 */
.status.connecting {
  color: #ffc107;
  animation: pulse 1.5s infinite;
}

.status.connected {
  color: #4caf50;
}

.status.disconnected {
  color: #f44336;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* 响应式优化 */
@media (max-width: 480px) {
  .ai-badge {
    font-size: 8px;
    padding: 1px 4px;
    top: -6px;
    right: -6px;
  }
  
  .typing-indicator {
    padding: 6px 10px;
  }
  
  .typing-dot {
    width: 5px;
    height: 5px;
  }
}
